package com.atguigu.tingshu.configuration;

import com.atguigu.tingshu.properties.XXLJobProperties;
import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class XXLJobConfiguration {

    @Autowired
    private XXLJobProperties xxlJobProperties ;

    @Bean
    public XxlJobSpringExecutor xxlJobSpringExecutor() {
        XxlJobSpringExecutor jobSpringExecutor = new XxlJobSpringExecutor() ;
        jobSpringExecutor.setAdminAddresses(xxlJobProperties.getAdminAddresses());
        jobSpringExecutor.setAccessToken(xxlJobProperties.getAccessToken());
        jobSpringExecutor.setAppname(xxlJobProperties.getAppName());
        jobSpringExecutor.setIp(xxlJobProperties.getIp());            // 执行器所在服务器的ip地址
        jobSpringExecutor.setPort(xxlJobProperties.getPort());                     // 执行器进程多对应的端口号
        return jobSpringExecutor ;
    }

}
